@extends('layout.master')

@section('content-header')
    <h1>Kipem</h1>
    <ol class="breadcrumb">
        <li><a href="/"><i class="fa fa-dashboard"></i> Dashboard</a></li>
        <li class="active"><i class="fa fa-file"></i> Kipem</li>
    </ol>
@stop

@section('content')
<div class="row">
    <div class="col-xs-12">

        <div class="box">
            <div class="box-body table-responsive">
                {{ HTML::decode(link_to_route('detail_kipems.create', '<i class="fa fa-plus-square"></i> Tambah Data', null, array('class'=>'btn btn-primary'))) }}
                <table id="my-table" class="table table-bordered table-striped">
                    <thead>
                        <tr class="center">
                            <th>#</th>
                            <th>Provinsi</th>
                            <th>Lama Berlaku</th>
                            <th>Harga</th>
                            <th width="10%">Action</th>
                        </tr>
                    </thead>
                    <tbody>
                    	<?php 
                    		$i = 1;
            			?>
						@foreach ($detailkipems as $detailkipem)
						<?php
                    		switch ($detailkipem->satuan_berlaku) {
                    			case '1':
                    				$satuan_berlaku = "Hari";
                    				break;
                    			case '2':
                    				$satuan_berlaku = "Bulan";
                    				break;
                    			case '3':
                    				$satuan_berlaku = "Tahun";
                    				break;
                    		}
                    	?>
	                        <tr>
	                            <td class="center">{{ $i }}</td>
	                            <td>{{ $detailkipem->nama_prov }}</td>
	                            <td>{{ $detailkipem->lama_berlaku }} {{ $satuan_berlaku }}</td>
	                            <td>Rp. {{ $detailkipem->harga }},-</td>
	                            <td class="text-center">
	                                <div class="btn-group">
	                                	{{ HTML::decode(link_to_route('detail_kipems.edit', '<i class="fa fa-pencil text-warning" data-toggle="tooltip" data-placement="top" data-original-title="Edit"></i>', $detailkipem->id, array('class'=>'btn btn-default btn-edit'))) }}
	                                	<a href="#" class="btn btn-default btn-delete" data-form='{{Form::model($detailkipem,array('route'=>array('detail_kipems.destroy',$detailkipem->id),'method'=>'DELETE','class'=>'formDelete'))}}{{Form::close()}}'><i class="fa fa-times text-danger" data-toggle="tooltip" data-placement="top" data-original-title="Delete"></i></a>
	                                </div>
	                            </td>
	                        </tr>
	                        <?php $i++ ?>
						@endforeach
                    </tbody>
                </table>
            </div><!-- /.box-body -->
        </div><!-- /.box -->
    </div>
</div>
@stop

@section('javascript')
<script type="text/javascript">
    $(function() {
       $('#my-table').dataTable({
            "bPaginate": true,
            "bLengthChange": false,
            "bSort": false,
            "bInfo": true,
            "bAutoWidth": false
        });

        $('.btn-delete').click(function(event) {
            event.preventDefault(); 
            formDelete = $(this).data('form');
            bootbox.confirm('Yakin hapus data ini?'+formDelete, function(yes){
                if(yes) {
                    $('.formDelete').submit();
                }
            });
        });
    });
</script>
@stop